package com.example.dogliving.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;

import com.example.dogliving.bean.ColumnBean;
import com.example.dogliving.columnmodle.ColumnModle;
import com.example.dogliving.columnmodle.IColumnCLassView;
import com.example.dogliving.columnmodle.IColumnModle;
import com.example.dogliving.columnmodle.OnLoadColumnListener;
import com.example.dogliving.fragment.column.ColumnAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 张博文 on 2016/12/27.
 */

public class ColumnPresenter {
    //绑定适配器，抛出错误
    private IColumnCLassView columnCLassView;
    //传递页面数据
    private IColumnModle iColumnModle;
    private List<ColumnBean.DataListBean> mList = new ArrayList<>();
    private ColumnAdapter adapter;

    public ColumnPresenter(IColumnCLassView columnClassView){
        this.columnCLassView=columnClassView;
        //网络加载
        this.iColumnModle=new ColumnModle();
    }
    //绑定适配器
    public void login(final Context context, final RecyclerView recyclerView){
        //加载实体类
        iColumnModle.login(new OnLoadColumnListener() {

            @Override
            public void onSucess(final ColumnBean columnBean) {
                mList = columnBean.getData_list();
                //绑定适配器
                adapter = new ColumnAdapter(context,mList,recyclerView);
                columnCLassView.toSetAdapter(adapter);

            }
            //如果加载失败  显示加载失败
            @Override
            public void onFailed(Exception e) {
                columnCLassView.showError(e);
            }
        });
    }

    //跳转界面

}
